function vstencil = readStencil(filename)
%READSTENCIL Summary of this function goes here
%   Detailed explanation goes here
    hd = fopen(filename, 'rb');
    D = fread(hd, 1, 'int');
    numItems = fread(hd, 1, 'int');
    vstencil = repmat(struct('idx',[0 0],'locations',0), ...
        [numItems 1]);
    for n=1:numItems
        vstencil(n).idx = fread(hd,[1 D],'int');
        numLocs = fread(hd, 1, 'int');
        vstencil(n).locations = fread(hd, [D numLocs],'int');
    end
    fclose(hd);
end

